import { extend, localize } from 'vee-validate'
import { max, length, required, email, min, is, confirmed, is_not } from 'vee-validate/dist/rules'
import zh from 'vee-validate/dist/locale/zh_CN.json'

extend('required', required)
extend('length', length)
extend('email', email)
extend('min', min)
extend('max', max)
extend('is', is)
extend('confirmed', confirmed)
extend('is_not', is_not)


localize('zh_CN', {
  messages: {
    ...zh.messages,
    required: '请输入{_field_}',
    is: '两次{_field_}输入不一致'
  },
  names: {
    username: '用户名',
    password: '密码',
    repassword: '确认密码',
    oldpassword: '旧密码',
    code: '验证码',
    nickname: '昵称',
    name: '昵称',
    email: '邮箱',
    title: '标题',
    catalog: '分类'
  },
  fields: {
    catalog: {
      is_not: '请选择{_field_}'
    },
    username: {
      email: '请填入邮箱作为您的{_field_}'
    },
    name: {
      min: (field, { length }) => {
        return `请在${field}输入至少${length}个字符!`
      }
    },
    password: {
      confirmed: (field, { target }) => {
        return `两次${field}输入不一致!`
      }
    }
  },
})